package com.ubing.boot.notesforjava.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 在 springboot中 , 配置 拦截器
 * @author beyondx
 * @date Created in 2022/08/13/ 15:21
 */
//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private CheckTokenInterceptor checkTokenIntercepotr;
    /**
     * @param registry 拦截器 的 注册器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 把 拦截器 注册到 Mvc, 同时 设置 拦截 和 放过的 信息
        registry.addInterceptor(checkTokenIntercepotr)
                .addPathPatterns("/**")
                .excludePathPatterns("/userInfo/login")
                .excludePathPatterns("/userInfo/register")
                .excludePathPatterns("/userInfo/avatarUpload")
                .excludePathPatterns("/userInfo/validateUserName")
                .excludePathPatterns("/avatar/**")
                .excludePathPatterns("/music/**")
                .excludePathPatterns("/error/exception")
                .excludePathPatterns("/noteInfo/getList")
                .excludePathPatterns("/noteInfo/excel");
    }
}
